package net.atomtree.controller;

import net.atomtree.entity.NoteResult;
import net.atomtree.service.AppService;
import net.sf.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by czk on 2015/12/31.
 */

@Controller
@RequestMapping("/engine")
public class AppController {
@RequestMapping("/index.do")
@ResponseBody
public NoteResult AppIndexController(HttpServletRequest request,HttpServletResponse response){
    String url="http://101.204.243.107:8080/api/v1";
    NoteResult result=new NoteResult();
    //通过8080rest api 得到当前所有运行的job的json数组
    JSONArray allAppJSONArray= null;
    try {
        allAppJSONArray = AppService.findAllApp(new StringBuffer(url));
        result.setData(allAppJSONArray);
        //成功
        result.setStatus(0);
        return result;
    } catch (Exception e) {
        e.printStackTrace();
    }
    //失败
    result.setStatus(1);
    result.setData(allAppJSONArray);
    return result;
}

}
